<?php


namespace App\Request;


use Hyperf\Validation\Request\FormRequest;

class BaseRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules():array
    {
        $rule_action = 'getRulesBy' . ucwords(substr($this->getUri()->getPath(),1));
        if (method_exists($this, $rule_action))
            return $this->$rule_action();

        return $this->getDefaultRules();
    }


    /**
     * 默认 验证规则
     * @return array
     */
    protected function getDefaultRules():array
    {
        return [];
    }
}